﻿using MediatR;
using SheepStorage.API.Application.Command.BuildingManagementCommand;
using SheepStorage.API.Application.Command.DepartmentCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.BuildingManagementCommandHandler
{
    public class BuildingManagementListCommandHandler : IRequestHandler<BuildingManagementListCommand, Results<PageOutput<BuildingManagement>>>
    {
        private readonly IBuildingManagementService buildingManagementService;

        public BuildingManagementListCommandHandler(IBuildingManagementService buildingManagementService)
        {
            this.buildingManagementService = buildingManagementService;
        }

        public async Task<Results<PageOutput<BuildingManagement>>> Handle(BuildingManagementListCommand request, CancellationToken cancellationToken)
        {
            return Results<PageOutput<BuildingManagement>>.DataResult(await buildingManagementService.GetBuildingManagement(request.BuildingName, request.pageIndex, request.pageSize));

        }
    }
}
